package lab.domain;

import java.io.Serializable;
import java.util.HashSet;

/**
 *
 * @author Smike
 */
public class ChangableHashSet<T> extends HashSet<T> implements Serializable {
    
    private transient Record record;
    
    public Record getRecord() {
        return record;
    }

    public void setRecord(Record record) {
        this.record = record;
    }

    @Override
    public boolean add(T e) {
        boolean result = super.add(e);
        notifyChanged();
        return result;
    }

    @Override
    public boolean remove(Object o) {
        boolean result = super.remove(o);
        notifyChanged();
        return result;
    }
    
    void notifyChanged() {
        if (record != null) {
            record.notifyChanged();
        }
    }
}
